<?php

use App\Http\Controllers\ActivityController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BannerController;
use App\Http\Controllers\CampController;
use App\Http\Controllers\ComboController;
use App\Http\Controllers\CommonController;
use App\Http\Controllers\FilterController;
use App\Http\Controllers\FoodController;
use App\Http\Controllers\LeaseController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\ProjectController;
use App\Http\Controllers\RefundController;
use App\Http\Controllers\SceneController;
use App\Http\Controllers\TradeController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\WriteOffController;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

// 上传
Route::post('upload', [CommonController::class, 'upload']);
// 筛选
Route::get('filter', [FilterController::class, 'list']);
// 营地
Route::prefix('camp')->group(function (Router $router) {
    // Banner
    $router->get('banner', [BannerController::class, 'list']);
    // 营地
    $router->controller(CampController::class)->group(function (Router $router) {
        // 首页
        $router->middleware('verify.userId')->get('index', 'index');
        // 营地详情
        $router->get('detail', 'detail');
        // 公司信息
        $router->get('company_info', 'companyInfo');
        // 公交列表
        $router->get('bus_list', 'busList');
        // 停车场列表
        $router->get('park_list', 'parkList');
    });
    // 套餐
    $router->controller(ComboController::class)->group(function (Router $router) {
        // 套餐列表
        $router->get('combo_list', 'list');
        // 套餐详情
        $router->get('combo_detail', 'detail');
    });
    // 租赁
    $router->controller(LeaseController::class)->group(function (Router $router) {
        // 租赁列表
        $router->get('lease_list', 'list');
        // 租赁详情
        $router->get('lease_detail', 'detail');
    });
    // 美食
    $router->controller(FoodController::class)->group(function (Router $router) {
        // 美食列表
        $router->get('food_list', 'list');
        // 美食详情
        $router->get('food_detail', 'detail');
    });
    // 活动
    $router->controller(ActivityController::class)->group(function (Router $router) {
        // 活动列表
        $router->get('activity_list', 'list');
        // 活动详情
        $router->get('activity_detail', 'detail');
    });
    // 项目
    $router->controller(ProjectController::class)->group(function (Router $router) {
        // 项目列表
        $router->get('project_list', 'list');
        // 项目详情
        $router->get('project_detail', 'detail');
    });
    // 风景
    $router->controller(SceneController::class)->group(function (Router $router) {
        // 风景列表
        $router->get('scene_list', 'list');
        // 风景详情
        $router->get('scene_detail', 'detail');
    });
    // 商务
    $router->controller(TradeController::class)->group(function (Router $router) {
        // 分类列表
        $router->get('cate_list', 'cateList');
        // 商务列表
        $router->get('trade_list', 'list');
        // 商务详情
        $router->get('trade_detail', 'detail');
    });
});

// 登录
Route::post('login', [AuthController::class, 'login']);
// 获取手机号
Route::post('get_phone', [AuthController::class, 'getPhone']);
// 支付回调
Route::any('order/notify', [OrderController::class, 'notify']);
// 退款回调
Route::any('refund/notify', [RefundController::class, 'notify']);
// 退款回调
Route::any('order/refund_check', [RefundController::class, 'refundCheck']);
// 登录之后
Route::prefix('user')->middleware(['verify.user'])->group(function (Router $router) {
    // 用户
    $router->controller(UserController::class)->group(function (Router $router) {
        // 编辑信息
        $router->post('edit_info', 'editInfo');
        // 编辑手机号
        $router->post('edit_phone', 'editPhone');
        // 用户中心
        $router->get('user_center', 'userCenter');
        // 用户信息
        $router->get('user_info', 'userInfo');
        // 通知列表
        $router->get('notice_list', 'noticeList');
    });
    // 订单
    $router->controller(OrderController::class)->group(function (Router $router) {
        // 美食购物车
        $router->post('food_cart', 'foodCart');
        // 订单预览
        $router->post('order_preview', 'orderPreview');
        // 下单
        $router->post('place_order', 'palaceOrder');
        // 支付
        $router->post('pay', 'pay');
        // 再来一单
        $router->post('order_again', 'orderAgain');
        // 订单列表
        $router->get('order_list', 'orderList');
        // 订单详情
        $router->get('order_detail', 'orderDetail');
        // 订单详情
        $router->post('del_order', 'delOrder');
    });
});
// 订单
Route::prefix('order')->middleware(['verify.user'])->group(function (Router $router) {
    // 核销
    $router->controller(WriteOffController::class)->group(function (Router $router) {
        // 核销
        $router->post('write-off', 'writeOff');
        // 核销记录
        $router->get('write-off-record', 'writeOffRecord');
    });
    // 退款
    $router->controller(RefundController::class)->group(function (Router $router) {
        // 退款
        $router->post('refund', 'refund');
        // 退款审核
//        $router->post('refund_check', 'refundCheck');
    });
});
